Generate locales used by the tests
authorSimon McVittie <smcv@debian.org>
Sat, 29 Feb 2020 17:14:46 +0000 (17:14 +0000)
committerSimon McVittie <smcv@debian.org>
Sat, 29 Feb 2020 23:33:08 +0000 (23:33 +0000)
debian/changelog
debian/control.in
debian/copyright
debian/rules
debian/run-with-locales [new file with mode: 0755]
debian/tests/control
debian/tests/installed-tests

index 15dbeb5b43505e93edfb21d36a4f8da93d1f604d..b0fd2327e75e8924de754403b76f410bcaed58ed 100644 (file)
@@ -31,6 +31,8 @@ gtk+4.0 (3.98.0-1) UNRELEASED; urgency=medium
   * d/rules: Update SONAME
   * d/rules: Adjust build options for rename of documentation to gtk_doc
   * d/rules: Sort build options
+  * d/run-with-locales, d/rules, d/tests/installed-tests:
+    Generate locales used by the tests
 
  -- Simon McVittie <smcv@debian.org>  Sat, 29 Feb 2020 14:18:02 +0000
 
index 198bc4bdb1dbcfa3ecfa2b63575bb8300b0c9993..5eb09703696da863efc85085d2dcac66894ca010 100644 (file)
@@ -43,6 +43,7 @@ Build-Depends: adwaita-icon-theme <!nocheck>,
                libxkbfile-dev,
                libxml2-utils,
                libxrandr-dev (>= 2:1.5.0),
+               locales | locales-all,
                meson (>= 0.50.1),
                pkg-config,
                sassc,
index da44c4979c39551b9cb90641ce2140df138c6d32..341b5efeaadfbb0d7b8018dea43f193969577518 100644 (file)
@@ -507,13 +507,15 @@ Copyright:
 License: LGPL-2+ or sun-permissive
 
 Files:
+ debian/run-with-locales
  gdk/wayland/cursor/*
  gtk/inspector/logs.*
 Copyright:
- 2002 Keith Packard
- 2012 Collabora Ltd.
+ 2012-2018 Collabora Ltd.
  2012 Intel Corporation
+ 2002 Keith Packard
  2018 Red Hat, Inc.
+ 2016-2020 Simon McVittie
 License: Expat
 
 Files:
index d4591d242c4fdb56220f1978cf4ffac3d1cf59e1..88939cb82eca126e78b3e27dd47c7bfdadf47cf1 100755 (executable)
@@ -178,6 +178,11 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
        # Remove LD_PRELOAD so we don't run with fakeroot, which makes dbus-related tests fail
        env -u LD_PRELOAD \
        xvfb-run -a -s "-screen 0 1024x768x24" \
+       debian/run-with-locales \
+               --generate de_DE.UTF-8 \
+               --generate en_GB.UTF-8 \
+               --generate en_US.UTF-8 \
+               --generate sv_SE \
        dh_auto_test --builddirectory=debian/build/deb -- -k 0 -j 1 || true
 endif
 
diff --git a/debian/run-with-locales b/debian/run-with-locales
new file mode 100755 (executable)
index 0000000..c3b192b
--- /dev/null
@@ -0,0 +1,122 @@
+#!/bin/sh
+#
+# Run a wrapped command with at least the requested locales available.
+# Requires a dependency on locales | locales-all.
+# The requested locales must be of the form foo_FOO.utf8, or special-cased
+# in generate().
+#
+# Copyright 2016-2020 Simon McVittie
+# Copyright 2017-2018 Collabora Ltd.
+#
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+set -eu
+
+me="$(basename "$0")"
+tempdir=
+
+usage () {
+    local status="${1-2}"
+
+    if [ "$status" -ne 0 ]; then
+        exec >&2
+    fi
+
+    echo "Usage: $me [--generate LOCALE...] COMMAND [ARGS...]"
+}
+
+getopt_temp=help
+getopt_temp="$getopt_temp,generate:"
+
+getopt_temp="$(getopt -o '' --long "$getopt_temp" -n "$0" -- "$@")"
+eval set -- "$getopt_temp"
+unset getopt_temp
+
+generate () {
+    local locale="$1"
+    local name
+    local charset
+
+    case "$locale" in
+        (*.utf8)
+            name="${locale%.utf8}"
+            charset=UTF-8
+            ;;
+
+        (sv_SE)
+            name="$locale"
+            charset=ISO-8859-1
+            ;;
+
+        (*)
+            echo "$me: Unsupported locale $locale" >&2
+            exit 1
+            ;;
+    esac
+
+    if [ -e "/usr/lib/locale/$locale/LC_MESSAGES/SYS_LC_MESSAGES" ]; then
+        return
+    fi
+
+    if [ -z "$tempdir" ]; then
+        tempdir="$(mktemp -d)"
+        trap 'rm -fr "$tempdir"' EXIT
+    fi
+
+    localedef -i "$name" -f "$charset" "$tempdir/$locale"
+}
+
+while [ "$#" -gt 0 ]; do
+    case "$1" in
+        (--help)
+            usage 2
+            # not reached
+            ;;
+
+        (--generate)
+            generate "$2"
+            shift 2
+            ;;
+
+        (--)
+            shift
+            break
+            ;;
+
+        (-*)
+            echo "$me: Unknown option: $1" >&2
+            usage 2
+            # not reached
+            ;;
+
+        (*)
+            break
+            ;;
+    esac
+done
+
+if [ -n "$tmpdir" ]; then
+    export LOCPATH="$tmpdir"
+fi
+
+"$@"
+
+# vim:set sw=4 sts=4 et:
index c91fbb221e03519c85ef69b9af0e17610c9f5258..2456ac91ed74f1f62e92244b4773b8d9d5d82045 100644 (file)
@@ -8,5 +8,5 @@ Depends: dbus, gir1.2-gtk-4.0, python3-gi, xauth, xvfb
 Restrictions: flaky, superficial
 
 Tests: installed-tests
-Depends: at-spi2-core, dbus (>= 1.8), gnome-desktop-testing (>= 2018.1-1~), gtk-4-examples, xauth, xvfb
+Depends: at-spi2-core, dbus (>= 1.8), gnome-desktop-testing (>= 2018.1-1~), gtk-4-examples, locales | locales-all, xauth, xvfb
 Restrictions: allow-stderr, flaky
index 4349fa049f086dd25691bb5b3bcae9988a2ad988..8848a5ae37431981a20651792df0956617f55c22 100755 (executable)
@@ -13,6 +13,11 @@ export XDG_RUNTIME_DIR="$AUTOPKGTEST_TMP"
 
 exec dbus-run-session -- \
 xvfb-run -a -s "-screen 0 1024x768x24" \
+debian/run-with-locales \
+    --generate de_DE.UTF-8 \
+    --generate en_GB.UTF-8 \
+    --generate en_US.UTF-8 \
+    --generate sv_SE \
 gnome-desktop-testing-runner \
 --report-directory="$AUTOPKGTEST_ARTIFACTS" \
 --tap \